Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection

Namespace CEL.Modules.CELLibrary
    Partial Class ViewBookDetails
        Inherits Entities.Modules.PortalModuleBase
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If IsPostBack = True Then Exit Sub
            Call LocalizeSetting()
            If Request.QueryString("LibraryID") <> "" Then Call loadLibraryData(Val(Request.QueryString("LibraryID")))
        End Sub
        Public Sub loadLibraryData(ByVal LibraryID As Integer)
            Dim objLibraryCon As New CELLibraryController
            Dim dtTable As DataTable = objLibraryCon.getLibraryByID(LibraryID)
            If dtTable.Rows.Count > 0 Then
                If Not IsDBNull(dtTable.Rows(0)("Author")) Then Me.lblAuthor.Text = dtTable.Rows(0)("Author")
                If Not IsDBNull(dtTable.Rows(0)("LibraryID")) Then Me.lblLibraryID.Text = dtTable.Rows(0)("LibraryID")
                If Not IsDBNull(dtTable.Rows(0)("ISBN")) Then Me.lblISB.Text = dtTable.Rows(0)("ISBN")
                If Not IsDBNull(dtTable.Rows(0)("OwnerID")) Then
                    Dim objUserCon As New UserController
                    Dim objUserInfo As UserInfo = objUserCon.GetUser(PortalId, Val(dtTable.Rows(0)("OwnerID")))
                    If Not objUserInfo Is Nothing Then Me.lblCurrentlyBorrowed.Text = objUserInfo.Username
                End If
                If Not IsDBNull(dtTable.Rows(0)("PublishDate")) Then Me.lblPublishDate.Text = dtTable.Rows(0)("PublishDate")
                If Not IsDBNull(dtTable.Rows(0)("Publisher")) Then Me.lblPublisher.Text = dtTable.Rows(0)("Publisher")
                If Not IsDBNull(dtTable.Rows(0)("Title")) Then Me.lblTitle.Text = dtTable.Rows(0)("Title")
                If Not IsDBNull(dtTable.Rows(0)("Media")) Then Me.lblMedia.Text = dtTable.Rows(0)("Media")
                dtTable = objLibraryCon.GetBorrowedBookByLibraryID(LibraryID)
                If dtTable.Rows.Count > 0 Then
                    If Not IsDBNull(dtTable.Rows(0)("BorrowDate")) Then Me.lblBorrowDate.Text = dtTable.Rows(0)("BorrowDate")
                    If Not IsDBNull(dtTable.Rows(0)("DueReturnDate")) Then Me.lblDueDate.Text = dtTable.Rows(0)("DueReturnDate")
                Else
                    Me.lblBorrowDate.Text = "&nbsp;"
                    Me.lblBorrowDateTitle.Text = "&nbsp;"
                    Me.lblDueDate.Text = "&nbsp;"
                    Me.lblDueDateTitle.Text = "&nbsp;"

                    Me.rowBorrow.Visible = False
                    Me.rowDueDate.Visible = False
                    'Me.lblDueDate.Visible = False
                    'Me.lblDueDateTitle.Visible = False

                End If
            End If
        End Sub
        Public Sub LocalizeSetting()
            Me.lblAuthorTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblAuthorTitle", Me.LocalResourceFile)
            Me.lblCurrentlyBorrowedTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblCurrentlyBorrowedTitle", Me.LocalResourceFile)
            Me.lblISBTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblISBTitle", Me.LocalResourceFile)
            Me.lblBorrowDateTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblBorrowDateTitle", Me.LocalResourceFile)
            Me.lblDueDateTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblDueDateTitle", Me.LocalResourceFile)
            Me.lblPublishDateTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblPublishDateTitle", Me.LocalResourceFile)
            Me.lblPublisherTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblPublisherTitle", Me.LocalResourceFile)
            Me.lnkBack.Text = DotNetNuke.Services.Localization.Localization.GetString("lnkBack", Me.LocalResourceFile)
            Me.lblMediaTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblMediaTitle", Me.LocalResourceFile)
            Me.lblTitleTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("lblTitleTitle", Me.LocalResourceFile)
        End Sub

        Protected Sub lnkBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkBack.Click
            If Request.QueryString("back") = "vbd" Then Response.Redirect(EditUrl("ManageBooks"), True)
            If Request.QueryString("back") = "arch" Then Response.Redirect(EditUrl("Archived"), True)
        End Sub
    End Class
End Namespace